<template>
  <van-nav-bar
    title="方剂学习"
    left-text="返回"
    left-arrow
    @click-left="go(parentId)"
  />
  <div v-for="item in bookDetail.details" :key="item.childId">
    {{ item.content }}
  </div>
</template>

<script>
export default {
  data() {
    return {
      getBookInfoQueryInfo: {
        methodName: "bookStudy_getBookInfo",
        data: { param: "" },
      },
      bookDetail: { id: "", details: [] },
      parentId: "",
    };
  },
  created() {
    this.getRouterParams();
    setTimeout(() => {
      this.getBookInfo();
    }, 100);
  },
  methods: {
    getRouterParams() {
      this.parentId = this.$route.query.id;
    },
    async getBookInfo() {
      this.getBookInfoQueryInfo.data.param = this.parentId;
      console.log(this.getBookInfoQueryInfo.data.param);
      const { data: res } = await this.$http.post(
        "/app/main",
        JSON.stringify(this.getBookInfoQueryInfo),
        {
          headers: {
            "Content-Type": "application/json",
          },
        }
      );
      console.log(JSON.parse(res.data));
      this.rootId = JSON.parse(res.data).rootID;
    },

    go() {
      this.$router.push({
        path: "/study",
      });
    },
  },
};
</script>

<style>
</style>